/*
 * All content copyright http://www.j2eefast.com, unless
 * otherwise indicated. All rights reserved.
 * No deletion without permission
 */
package com.clwl.supervise.superviseapp.controller.certificaReview;

import com.clwl.supervise.superviseapp.beans.certificaReview.CertificaReviewSearchParams;
import com.clwl.supervise.superviseapp.beans.certificaReview.CertificaReviewVo;
import com.clwl.supervise.superviseapp.entity.result.ResultEntity;
import com.clwl.supervise.superviseapp.service.certificaReview.JgCertificaReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 证后审查控制器
 * @author GuXueJian
 * @date 2023-10-13 13:49:07
 */
@RestController
@RequestMapping("certificareview")
public class JgCertificaReviewController {


    @Autowired
    private JgCertificaReviewService jgCertificaReviewService;

    /**
     * 获取证后审查--列表
     * @param pageNum
     * @param pageSize
     * @param params
     * @return
     */
    @GetMapping("getList")
    private ResultEntity<List<CertificaReviewVo>> getList(@RequestParam(required = true) Integer pageNum, @RequestParam(required = true) Integer pageSize, CertificaReviewSearchParams params){
        Map<String, Object> resultMap=  jgCertificaReviewService.getCertificaReviewVoList(pageNum,pageSize,params);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取证后审查列表信息失败");
        }
        if("1".equals(resultMap.get("code"))){
            return ResultEntity.error((String)resultMap.get("msg"));
        }
        List<CertificaReviewVo> data= (List<CertificaReviewVo>) resultMap.get("data");
        return ResultEntity.success(data);
    }

    /**
     * 获取年份列表
     * @return
     */
    @GetMapping("getCheckYearList")
    private ResultEntity<List<String>> getCheckYearList(){
        List<String> yearList=  jgCertificaReviewService.getCheckYearList();
        return ResultEntity.success(yearList);
    }

    /**
     * 获取监管人员列表
     * @param pageNum
     * @param pageSize
     * @param params
     * @return
     */
    @GetMapping("getSupervisors")
    private ResultEntity<Map<String, Object> > getSupervisors(@RequestParam(required = true) Integer pageNum, @RequestParam(required = true) Integer pageSize,Long companyId, String name,String  userRole){
        Map<String, Object> resultMap=  jgCertificaReviewService.getSupervisors(pageNum,pageSize,companyId,name,userRole);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取监管人员列表信息失败");
        }
        if("1".equals(resultMap.get("code"))){
            return ResultEntity.error((String)resultMap.get("msg"));
        }
        return ResultEntity.success((Map<String, Object>)resultMap.get("data"));
    }

    /**
     * 获取审查专家列表
     * @param pageNum
     * @param pageSize
     * @param params
     * @return
     */
    @GetMapping("getExpertArchives")
    private ResultEntity<Map<String, Object> > getExpertArchives(@RequestParam(required = true) Integer pageNum, @RequestParam(required = true) Integer pageSize, Long companyId,String  name){
        Map<String, Object> resultMap=  jgCertificaReviewService.getExpertArchives(pageNum,pageSize,companyId,name);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取审查专家列表信息失败");
        }
        if("1".equals(resultMap.get("code"))){
            return ResultEntity.error((String)resultMap.get("msg"));
        }
        return ResultEntity.success((Map<String, Object>)resultMap.get("data"));
    }

    /**
     * 保存审查信息
     * @param params
     * @return
     */
    @PostMapping("saveReviewEnterInfo")
    private @ResponseBody ResultEntity saveReviewEnterInfo(@RequestBody String params){
        Map<String, Object> resultMap=  jgCertificaReviewService.saveReviewEnterInfo(params);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取监管人员列表信息失败");
        }
        if("1".equals(resultMap.get("code"))){
            return ResultEntity.error((String)resultMap.get("msg"));
        }
        return ResultEntity.success();
    }
    /**
     * 获取证后审查--审查录入信息
     * @param id
     * @return
     */
    @GetMapping("getReviewEnterInfo")
    private ResultEntity<Map<String, Object>> getReviewEnterInfo(Long id){
        Map<String, Object> resultMap=  jgCertificaReviewService.getCertificaReviewEnterInfo(id);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取证后审查录入信息失败");
        }
        if("1".equals(resultMap.get("code"))){
            return ResultEntity.error((String)resultMap.get("msg"));
        }
        Map<String, Object> data= (Map<String, Object>) resultMap.get("data");
        return ResultEntity.success(data);
    }

    /**
     * 获取证后审--查明细信息
     * @param id
     * @return
     */
    @GetMapping("getDetail")
    private ResultEntity<Map<String, Object>> getDetail(Long id){
        Map<String, Object> resultMap=  jgCertificaReviewService.getCertificaReviewDtl(id);
        if(null==resultMap||resultMap.isEmpty()){
            return ResultEntity.error("获取证后审查明细信息失败");
        }
        if("1".equals(resultMap.get("code"))){
            return ResultEntity.error((String)resultMap.get("msg"));
        }
        Map<String, Object> data= (Map<String, Object>) resultMap.get("data");
        return ResultEntity.success(data);
    }
}
